﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
    class dbHelper
    {
        static string strConn = "Data Source=.;Initial Catalog=DBHome;Integrated Security=True";
        public static DataSet GetData(string sql)
        {
            SqlDataAdapter da = new SqlDataAdapter(sql, strConn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            return ds;
        }
        public static bool ExecuteNonQuery(string sql)
        {
            SqlConnection conn = new SqlConnection(strConn);
            SqlCommand cmd = new SqlCommand(sql, conn);
            try
            {
                if (conn.State==ConnectionState.Closed)
                {
                    conn.Open();
                }
                return cmd.ExecuteNonQuery()>0;
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
    }
}
